// 明星
const star = {
  name: "刘德华",
  age: 60,
  phone: "18611112222",
  price: 0, // 报价
};

// 经纪人
const agent = new Proxy(star, {
  get(target, key) {
    switch (key) {
      case "phone":
        return "13988888888";
      case "price":
        return 100 * 1000; // 报价
      default:
        return Reflect.get(target, key); // 返回原来的属性值
    }
  },
  set(target, key, val) {
    switch (key) {
      case "price":
        if (val < 100 * 1000) throw new Error("价格太低了...");
        else return Reflect.set(target, key, val);
      default:
        return false; // 其他属性不可设置
    }
  },
});

// 主办方
console.log(agent.name);
console.log(agent.age);
console.log(agent.phone);
console.log(agent.price);
// agent.price = 90000; // 抛出错误
